﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using UnitFundProfitability.BusinessLogic;

namespace UnitFundProfitability.BusinessLogicTest
{
    /// <summary>
    ///This is a test class for Manager_FundSnapshotTest and is intended
    ///to contain all Manager_FundSnapshotTest Unit Tests
    ///</summary>
    [TestClass()]
    public class Manager_FundSnapshotTest
    {
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for FundSnapshot Constructor
        ///</summary>
        [TestMethod()]
        [DeploymentItem("UnitFundProfitability.BusinessLogic.dll")]
        public void Manager_FundSnapshotConstructorTest()
        {
            Exception exception = null;
            try
            {
                Manager_Accessor.FundSnapshot target = new Manager_Accessor.FundSnapshot();
            }
            catch (Exception ex)
            {
                exception = ex;
            }
            Assert.IsNull(exception);
        }

        /// <summary>
        ///A test for UpdateWithExpenditureOperation
        ///</summary>
        [TestMethod()]
        [DeploymentItem("UnitFundProfitability.BusinessLogic.dll")]
        public void UpdateWithExpenditureOperationTest()
        {
            Manager_Accessor.FundSnapshot target = new Manager_Accessor.FundSnapshot();
            Income income = new Income();
            income.MoneyAmount = 4;
            income.UnitsAmount = 2;
            target.UpdateWithIncomeOperation(income);
            Expenditure expenditure = new Expenditure();
            expenditure.MoneyAmount = 3;
            expenditure.UnitsAmount = 1;
            target.UpdateWithExpenditureOperation(expenditure);
            Assert.AreEqual(2, target.MoneyIncome);
            Assert.AreEqual(1, target.UnitsCount);
        }

        /// <summary>
        ///A test for UpdateWithIncomeOperation
        ///</summary>
        [TestMethod()]
        [DeploymentItem("UnitFundProfitability.BusinessLogic.dll")]
        public void UpdateWithIncomeOperationTest()
        {
            Manager_Accessor.FundSnapshot target = new Manager_Accessor.FundSnapshot();
            Income income = new Income();
            income.MoneyAmount = 4;
            income.UnitsAmount = 2;
            target.UpdateWithIncomeOperation(income);
            Assert.AreEqual(4, target.MoneyIncome);
            Assert.AreEqual(2, target.UnitsCount);
        }

        /// <summary>
        ///A test for MarkdownRate
        ///</summary>
        [TestMethod()]
        [DeploymentItem("UnitFundProfitability.BusinessLogic.dll")]
        public void MarkdownRateTest()
        {
            Manager_Accessor.FundSnapshot target = new Manager_Accessor.FundSnapshot();
            decimal expected = 125.346M;
            decimal actual;
            target.MarkdownRate = expected;
            actual = target.MarkdownRate;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for MoneyIncome
        ///</summary>
        [TestMethod()]
        [DeploymentItem("UnitFundProfitability.BusinessLogic.dll")]
        public void MoneyIncomeTest()
        {
            Manager_Accessor.FundSnapshot target = new Manager_Accessor.FundSnapshot();
            Income income = new Income();
            income.MoneyAmount = 4;
            income.UnitsAmount = 2;
            target.UpdateWithIncomeOperation(income);
            Expenditure expenditure = new Expenditure();
            expenditure.MoneyAmount = 2;
            expenditure.UnitsAmount = 1;
            target.UpdateWithExpenditureOperation(expenditure);
            decimal actual = target.MoneyIncome;
            Assert.AreEqual(2, actual);
        }

        /// <summary>
        ///A test for PossibleMoneyExpenditure
        ///</summary>
        [TestMethod()]
        [DeploymentItem("UnitFundProfitability.BusinessLogic.dll")]
        public void PossibleMoneyExpenditureTest()
        {
            Manager_Accessor.FundSnapshot target = new Manager_Accessor.FundSnapshot();
            Income income = new Income();
            income.MoneyAmount = 4;
            income.UnitsAmount = 2;
            target.UpdateWithIncomeOperation(income);
            Expenditure expenditure = new Expenditure();
            expenditure.MoneyAmount = 2;
            expenditure.UnitsAmount = 1;
            target.UpdateWithExpenditureOperation(expenditure);
            target.MarkdownRate = 0.015M;
            target.UnitPrice = 3;
            decimal actual = target.PossibleMoneyExpenditure;
            Assert.AreEqual(2.83085M, actual);
        }

        /// <summary>
        ///A test for UnitPrice
        ///</summary>
        [TestMethod()]
        [DeploymentItem("UnitFundProfitability.BusinessLogic.dll")]
        public void UnitPriceTest()
        {
            Manager_Accessor.FundSnapshot target = new Manager_Accessor.FundSnapshot();
            Decimal expected = 123.456M;
            Decimal actual;
            target.UnitPrice = expected;
            actual = target.UnitPrice;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for UnitsCount
        ///</summary>
        [TestMethod()]
        [DeploymentItem("UnitFundProfitability.BusinessLogic.dll")]
        public void UnitsCountTest()
        {
            Manager_Accessor.FundSnapshot target = new Manager_Accessor.FundSnapshot(); // TODO: Initialize to an appropriate value
            decimal actual;
            actual = target.UnitsCount;
            Assert.AreEqual(0, actual);
            Income income = new Income();
            income.MoneyAmount = 4;
            income.UnitsAmount = 2;
            target.UpdateWithIncomeOperation(income);
            actual = target.UnitsCount;
            Assert.AreEqual(2, actual);
            Expenditure expenditure = new Expenditure();
            expenditure.MoneyAmount = 3;
            expenditure.UnitsAmount = 1;
            target.UpdateWithExpenditureOperation(expenditure);
            actual = target.UnitsCount;
            Assert.AreEqual(1, actual);
        }
    }
}
